package be.bejug.scrumadmin;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.stereotype.Component;

import be.bejug.scrumadmin.components.panels.ContentPanel;
import be.bejug.scrumadmin.spring.BaseApplication;
import be.bejug.scrumadmin.utils.VaadinApplicationObjectSupport;

import com.vaadin.ui.Window;

/**
 * The Application's "main" class
 */
@Component(value = "scrumAdminApplication")
@Scope(value = "prototype")
public class ScrumAdminApplication extends BaseApplication {
	/**
	 * Serial Version UID.
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * SLF4J logger for logging stuff.
	 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private VaadinApplicationObjectSupport applicationObjectSupport;

	@Autowired
	private KnowledgeCenter knowledgeCenter;

	private MainView mainView;

	private Window mainWindow;

	/**
	 * Initialize the application, panels and other components.
	 */
	@Override
	public void init() {
		if (logger.isDebugEnabled()) {
			logger.debug("Initializing application [" + this + "]");
		}

		setTheme("scrumadmin");

		mainView = new MainView(new ContentPanel());
		mainView.setSizeFull();
		mainWindow = new Window(getApplicationObjectSupport().getMessage(
				"application.name", getVersion()), mainView);

		knowledgeCenter = new KnowledgeCenter();

		setMainWindow(mainWindow);
	}

	/**
	 * Gets the {@link ApplicationObjectSupport}.
	 * 
	 * @return the applicationObjectSupport
	 */
	public VaadinApplicationObjectSupport getApplicationObjectSupport() {
		return applicationObjectSupport;
	}

	/**
	 * @return the mainView
	 */
	public MainView getMainView() {
		return mainView;
	}

}
